In this task, I will be working with spatial data regarding the 2008 California DFW oil spill. The analysis will include an interactive tmap of the oil spill sites, and a static choropleth map for which color of each county depends on the count of inland oil spill events.
ca_oil_spill_sf <- read_sf(here('data/oil_spill/ds394.shp')) %>%
clean_names()
ca_counties_sf <- read_sf(here('data/ca_counties/CA_Counties_TIGER2016.shp'))
ca_subset_sf <- ca_counties_sf %>%
clean_names() %>%
select(county_name = name, land_area = aland)
head(ca_oil_spill_sf)
## Simple feature collection with 6 features and 12 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -131184.3 ymin: -592855.8 xmax: 506070.5 ymax: -29107.6
## Projected CRS: NAD83 / California Albers
## # A tibble: 6 x 13
## dfgcontrol oesnumber dateofinci timeofinci inlandmari specificlo water
## <chr> <chr> <date> <chr> <chr> <chr> <chr>
## 1 08FG1315 08-2566 2008-04-04 1100 Marine Marine Yes
## 2 08FG0798 08-1391 2008-02-17 0632 Inland Fresh Water Yes
## 3 08FG3355 08-7520 2008-10-16 1737 Inland Fresh Water Yes
## 4 08FG3531 08-7979 2008-10-30 1700 Inland Fresh Water Yes
## 5 08FG2139 08-4440 2008-06-22 0449 Inland Fresh Water Yes
## 6 08FG3543 08-8018 2008-11-02 0830 Inland Fresh Water Yes
## # ... with 6 more variables: waterway <chr>, localecity <chr>,
## # localecoun <chr>, latitude <dbl>, longitude <dbl>, geometry <POINT [m]>
head(ca_subset_sf)
## Simple feature collection with 6 features and 2 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -13565690 ymin: 3862173 xmax: -13096340 ymax: 4833572
## Projected CRS: WGS 84 / Pseudo-Mercator
## # A tibble: 6 x 3
## county_name land_area geometry
## <chr> <dbl> <MULTIPOLYGON [m]>
## 1 Sierra 2468694587 (((-13431320 4821511, -13431313 4821520, -13431300 ~
## 2 Sacramento 2499183617 (((-13490651 4680832, -13490511 4680817, -13490465 ~
## 3 Santa Barbara 7084000598 (((-13423117 4042044, -13423158 4043249, -13422800 ~
## 4 Calaveras 2641820834 (((-13428575 4627725, -13428535 4627889, -13428535 ~
## 5 Ventura 4773390489 (((-13317854 3931602, -13317828 3932624, -13317686 ~
## 6 Los Angeles 10510651024 (((-13210018 3958856, -13210085 3959984, -13209920 ~
ca_oil_spill_sf <-
st_transform(ca_oil_spill_sf,
st_crs(ca_subset_sf))
tmap_mode(mode = 'view')
tm_shape(ca_subset_sf) +
tm_fill('county_name', legend.show = FALSE) +
tm_shape(ca_oil_spill_sf) +
tm_dots()